<template>
  <view class="sys_dept_add_container">
    <view class="example">
      <uni-forms ref="form" :model="form" labelWidth="80px">
    <uni-forms-item label="父部门id" name="parentId"  >
      <uni-easyinput v-model="form.parentId" placeholder="请输入父部门id" />
    </uni-forms-item>
    <uni-forms-item label="部门名称" name="deptName"  >
      <uni-easyinput v-model="form.deptName" placeholder="请输入部门名称" />
    </uni-forms-item>
    <uni-forms-item label="显示顺序" name="orderNum"  >
      <uni-easyinput v-model="form.orderNum" placeholder="请输入显示顺序" />
    </uni-forms-item>
    <uni-forms-item label="负责人" name="leader"  >
      <uni-easyinput v-model="form.leader" placeholder="请输入负责人" />
    </uni-forms-item>
    <uni-forms-item label="联系电话" name="phone"  >
      <uni-easyinput v-model="form.phone" placeholder="请输入联系电话" />
    </uni-forms-item>
    <uni-forms-item label="邮箱" name="email"  >
      <uni-easyinput v-model="form.email" placeholder="请输入邮箱" />
    </uni-forms-item>
    <uni-forms-item label="删除标志" name="delFlag"  >
      <uni-easyinput v-model="form.delFlag" placeholder="请输入删除标志" />
    </uni-forms-item>
      </uni-forms>
      <view class="button-group">
        <button type="default" style="padding:0 3em;font-size:14px"  class="button" @click="reset">重置</button>
        <button type="primary" style="padding:0 3em;font-size:14px"  class="button" @click="submit">提交</button>
      </view>
    </view>
  </view>
</template>


<script>
    import { addDept,getDept,listDept } from "@/api/system/dept";
    import {getSelectDict} from "@/utils/dict";
export default {
components: {
},
data() {
  return {
    //字典类型筛选options
    form: {},
    rules: {
    }
  }
},
onLoad(option) {
  //字典类型查询
},
onReady() {
  this.$refs.form.setRules(this.rules)
},
methods: {
  /* 提交*/
  submit() {
    console.log(this.form)
    this.$refs.form.validate().then(res => {
      addDept(this.form).then(response => {
        this.$modal.msgSuccess("新增成功")
        setTimeout(() => {
          // 返回到上一级父页面
          this.$tab.navigateBack();
        },500)
      })
    })
  },
  /* 表单重置*/
  reset(){
    this.form = {
       deptId: undefined,
       parentId: undefined,
       ancestors: undefined,
       deptName: undefined,
       orderNum: undefined,
       leader: undefined,
       phone: undefined,
       email: undefined,
       status: undefined,
       delFlag: undefined,
       createBy: undefined,
       createTime: undefined,
       updateBy: undefined,
       updateTime: undefined
    };
  }
}
}
</script>

<style lang="scss">
  page {
    background-color: #ffffff;
  }

  .sys_dept_add_container {
    .example {
      padding: 15px;
      background-color: #fff;
    }

    .button-group {
      margin-top: 15px;
      display: flex;
      justify-content: space-around;
    }
  }
</style>